﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="HighlightNewsAtHomePage.ascx.cs" Inherits="GUI.Controls.Sport.HighlightNewsAtHomePage" %>
<div class="left fl">
    <div id="divSlideSport" class="clearfix">
        <asp:Literal ID="ltrTopItem" runat="server"></asp:Literal>
    </div>
    <div class="sliderthethao fl">
        <ul>
            <asp:Literal ID="ltrList" runat="server"></asp:Literal>
        </ul>
    </div>
</div>
<script type="text/javascript">
    var slideSport = {
        currentIndex: 1,
        pause: false,
        init: function () {
            var me = this;
            var allItem = $(".sliderthethao li");
            if (allItem.length > 0) {
                allItem.each(function () {
                    $(this).hover(function () { slideSport.pause = !slideSport.pause; });
                    $(this).click(function (e) {
                        e.preventDefault();
                        slideSport.activeItem($(this));
                        slideSport.pause = true;
                    });
                });
                $(".sliderthethao ul li.hidden").removeClass("hidden");
                $(".sliderthethao ul li:first").addClass("hidden");
                $(".sliderthethao ul li.first").removeClass("first");
                $(".sliderthethao ul li:not(.hidden):first").addClass("first");
                setInterval(
            function () {
                if (!slideSport.pause) {
                    me.currentIndex++;
                    if (me.currentIndex == allItem.length) {
                        me.currentIndex = 0;
                    }
                    me.activeItem(allItem[me.currentIndex]);
                }
            }, 5000);
            }
        },

        activeItem: function (item) {
            var html = $(item).html();
            $("#divSlideSport").html(html);
            $("#divSlideSport .hidden").removeClass("hidden");
            $(".sliderthethao ul li.hidden").removeClass("hidden");
            $(item).addClass("hidden");
            $(".sliderthethao ul li.first").removeClass("first");
            $(".sliderthethao ul li:not(.hidden):first").addClass("first");

        }
    };
    slideSport.init();
</script>
